import { request } from '@/utils/request';
import { RequestEnum } from '@/enums/httpEnum';

export const foodApi = {
  foodList: '/food/list',
  foodDetail: '/food/detail',
  foodAdd: '/food/add',
  foodUpdate: '/food/update',
  foodDelete: '/food/delete',
  foodEnabled: '/food/enabled',
} as const;

export const createFood = (data: API.CreateFoodParams) => {
  return request({
    url: foodApi.foodAdd,
    method: RequestEnum.POST,
    data,
  });
};

export const updateFood = (data: API.UpdateFoodParams) => {
  return request({
    url: foodApi.foodUpdate,
    method: RequestEnum.PUT,
    data,
  });
};

export const deleteFood = (params: { id: number }) => {
  return request({
    url: foodApi.foodDelete,
    method: RequestEnum.DELETE,
    params,
  });
};

export const enabledFood = (params: { id: number }) => {
  return request({
    url: foodApi.foodEnabled,
    method: RequestEnum.POST,
    params,
  });
};
